package com.trip.common.vo;

import lombok.Data;
import lombok.ToString;

import java.util.HashMap;

import static com.trip.common.vo.DataDictionary.FAIL;

@Data
@ToString
public class Result {
    private Integer code;
    private String msg;
    private HashMap<String,Object> data;
    private Object res;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code , Object res , String msg) {
        this.code = code;
        this.msg = msg;
        this.res = res;
    }

    public Result(Integer code, String msg, HashMap<String,Object> data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result error(Integer code, String msg){
        return new Result(code,msg);
    }

    public static Result error(String msg){
        return new Result(DataDictionary.FAIL,msg);

    }

    public static Result ok(String msg, HashMap<String,Object> data){
        return new Result(DataDictionary.SUCCESS,msg,data);
    }

    public static Result ok(Object res,String msg){
        return new Result(DataDictionary.SUCCESS,res,msg);
    }
    public static Result ok(String msg){
        return new Result(DataDictionary.SUCCESS,msg);
    }
}
